home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-05 | 17.8 KB | 605 lines | [TEXT/PJMM] |
- unit PancakeCommon;
- interface
- {$IFC MWerks}
- uses
- Types, Files, Windows, Menus, Memory, Dialogs, Fonts, TextUtils, Packages;
- {$ENDC}
-
- const
- Keypad = 'ABCDEFGHIJKLMNOPRSTUVWXY';
- PossTypeable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-_+={}[]:;"<,>.?/|\~` ''éå∫ç∂´ƒ©˙^Δ˚¬µøπœ®ß†¨√∑≈¥ΩÅıÇΉÏÌÓÈÔÒ˜ˆØ∏ŒÂÍÊË◊„ÙÁÛ¡™£¢∞§¶•ªº–≠⁄€‹›fifl‡°·‚—±”’“‘ÚÆ…æ≤≥¯˘÷¿»«Ÿ';
- PossPrintable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-_+={}[]:;"<,>.?/|\~` ''';
- PossUsername = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
- PossPhone = '1234567890-';
- MacJmp = $120; {[PTR2LONG]}
- TabEqualsSpace = false;
- InputBufSize = 512;
- ModGeneva = 128;
- IBMCharset = 129;
- BoldIBMCharset = 130;
- Creator = 'Cake';
- UserType = 'User';
- PrefType = 'Pref';
- DataType = 'DATA';
- ExternType = 'XPan';
- TextType = 'TEXT';
- Version = '1.0';
- Null = chr(0);
- EscCode = chr(1);
- ControlC = chr(3);
- BackSpace = chr(8);
- Tab = chr(9);
- Linefeed = chr(10);
- Return = chr(13);
- CntrlX = chr(24);
- Escape = chr(27);
- Destructive = chr(127);
- tooManyNodesErr = -13542;
- MaxNodes = 22; {Normally 22}
- MaxPorts = 3; {Normally 3}
- MaxMenus = 20;
- EditTextStart = 1; {Window Types}
- EditTextEnd = 10;
- UserEdit = 11;
- GroupEdit = 12;
- StringEdit = 13;
- PortPrefs = 14;
- SysPrefs = 15;
- ScreenSaver = 16;
- AboutBox = 17;
- BoardStatus = 18;
- PortStatus = 19;
- Diagnostic = 20;
- MenuEdit = 21;
- NodeStart = 100;
- NodeEnd = NodeStart + MaxNodes;
- ScrollBackLines = 250;
- MaxX = 80;
- MaxY = 24;
- IncX = 6;
- IncY = 11;
- MemBuffer = 61440;
- InitExt = 1;
- Idle = 2;
- KeyPressed = 3;
- DisposeExt = 4;
- DisposeGlobal = 5;
-
- type
- str16 = string[16];
- str8 = string[8];
- systemRec = record
- version, numUsers, numGroups, numCookies, numPorts, logMain, callsToday: integer;
- maxPageCalls, maxPageSegments, maxPageDigits, windowsOpen, validPaths: integer;
- lastCaller, NUP: str16;
- checkNUP, unusedUseMe, speakReason, excuseBefore, sysopAvail, pagingOn, encodeLetters: boolean;
- postLocally: boolean;
- portStatusRect, boardStatusRect: rect;
- pageAcs, netPostAcs: string[25];
- pagerPhone: string[41];
- uucpNode: str16;
- timezone: string[5];
- curDay, curMonth, lastCall: longint;
- organization, newsFrom, domainName: string[59];
- paths: array[1..8] of string[127];
- uucpPort, suckerPort, termPort: integer;
- spoolPath, slurpSpoolPath, mailPath: string[127];
- localPass: str16;
- localProtection, uucpMail: boolean;
- mailService: str16;
- receiveMailAcs, sendMailAcs: string[25];
- seqf: integer;
- mailFrom: string[59];
- saverEnabled: boolean;
- saverIdle: integer;
- checkPopMail, smtpServerEnabled, smtpMail: boolean;
- popServer, smtpRelay: str31;
- uucpKickUsers, strictPhone: boolean;
- uucpLaunchEvery: integer;
- uucpLaunchedLast: longint;
- phoneFormat: str31;
- uucp, uucpFile, parser, term, sucker: FSSpec;
- bbsName: str31;
- suckerKickUsers: boolean;
- suckerLaunchEvery: integer;
- suckerLaunchedLast: longint;
- telnetAcs, fingerOutAcs: string[25];
- pppPort: integer;
- pppEnable, pppOpen, pppClose, pppHard: boolean;
- chatSound, sosSound: str32;
- printAcs, chatAcs, sosAcs: string[25];
- numMenus: integer;
- redirectAcs: string[25];
- passwordsEcho, hotkeyMenuFirst: boolean;
- end;
- asyncWritePtr = ^asyncWriteRec;
- asyncWriteRec = record
- pb: ParamBlockRec;
- nextPtr: asyncWritePtr;
- data: packed array[1..32000] of byte;
- end;
- carrierType = (NoDetection, Bob, CTS, DCDchip, DCDdriver);
- portType = (Serial, TCP, AppleTalk, SysopLocal);
- portSavRec = record
- nodeRect: rect;
- timeout, maxConns: integer;
- connAcs: string[25];
- callSound: str32;
- res: packed array[1..255] of byte;
- case typePort : portType of
- Serial: (
- typeCarrier: CarrierType;
- baud: longint;
- modemDriver, serialPort: integer;
- hwHand, pageable: boolean;
- res1: packed array[1..255] of byte;
- );
- TCP: (
- tcpPort: integer;
- enableFinger: boolean;
- res2: packed array[1..255] of byte;
- );
- AppleTalk: (
- adspName: str32;
- res3: packed array[1..255] of byte;
- );
- end;
- portGlobRec = record
- sessions, openPort, oldStatusLen: integer;
- lastInit: longint;
- connectionLost, inUse: boolean;
- status: string[80];
- case portType of
- Serial: (
- modemSection: (Hangup, InitSerial, PortIsBad, PortIsBusy, Offline, InitModem, GetOk, Awaiting, Answering);
- modemRedirecting: boolean;
- inRefnum, outRefnum: integer;
- inputBuffer: ptr;
- topWritePtr: asyncWritePtr;
- );
- TCP: (
- tcpSection: (InitTCP, GotError, AwaitingOpen, Connecting, CloseConn);
- fingerInSection: (OpenFingerIn, GotFingerErr, WaitingForFinger, NeedName, SendFingerInfo, CloseFingerIn);
- curTcpRefnum, fingerRefnum: integer;
- fingerName: string[80];
- );
- AppleTalk: (
- atlkSection: (InitAtlk, GotAtlkError, AwaitingAtlkOpen, AtlkConnecting, AtlkCloseConn);
- clConnRefnum, curConnRefnum: integer;
- );
- end;
- boardGlobRec = record
- done, screenSaverUp, inBackground, uucpLoaded, termLoaded, pageQueued, localLocked: boolean;
- windowsDirty, menusLocked, lpBeeped, kickingUUCPUsers, kickingSuckerUsers: boolean;
- suckerLoaded, editingPorts: boolean;
- lastResRefnum, strResRefnum, sndResRefnum, txtResRefnum, groupCheck, lpPos: integer;
- groupsStamp, lastIdleMess, gestaltOSAttrResult: longint;
- addedHotkey: str32;
- end;
- displayPtr = ^displayRec;
- displayRec = record
- cx, cy, sx, sy, head, tail, linesSincePause, param, scrollMTop, scrollMBot: integer;
- nodeWind: WindowPtr;
- scroll: ControlHandle;
- lastClick: longint;
- pasteHand: handle;
- cursorRect, selRect: rect;
- params: array[1..5] of byte;
- reversed, blinkOn, inScrollBack, inEsc, questMark: boolean;
- afterEsc: (OpenBracket, OpenParanth, CloseParanth);
- screen: packed array[1..MaxY, 0..MaxX] of byte;
- scrollback: packed array[1..ScrollBackLines, 0..MaxX] of byte;
- end;
- joinRec = record
- groupHash, numRead: longint;
- end;
- joinHand = ^joinPtr;
- joinPtr = ^joinArr;
- joinArr = array[1..32768] of joinRec;
-
- userRecPtr = ^userRec;
- userRec = record
- userName, password: str16;
- shell, localEdit, remoteEdit: str8;
- name, phone: string[32];
- timeOnToday, extraTime, firstLogin, previousLogin, upload, download: longint;
- minsPerDay, userNum: integer;
- accessLevel, priv, linesPerPage: byte;
- male: boolean;
- birthday: longint;
- comment: string;
- emulation: (tty, vt100, ansi, tek, rip);
- checkPop: boolean;
- selGroup: integer;
- res: packed array[1..37] of byte;
- end;
-
- mailIndexRec = record
- loc, len: longint;
- deleted: boolean;
- priv: packed array[1..25] of byte;
- end;
- mailIndexHand = ^mailIndexPtr;
- mailIndexPtr = ^mailIndexArr;
- mailIndexArr = array[1..32768] of mailIndexRec;
-
- shellType = (Waffle, Hotkey, Other);
- nodeActionType = (None, Prompting, Listing, Chatting, LineChatting, Transfering, Editor, Extern, Menu);
- nodeSectionType = (Shell, Logon, NewUser, ListingUsers, Feedback, Mailing, ReadingMail, Chat, Select, Rn, Post, Join, Finger, Telnet, Page, ChangeShell, ChangeEdit, Edit, AreYouSure, Help, Redirect, OneLiner, MultiChat, Download);
- nodeGlobPtr = ^nodeGlobRec;
- nodeGlobRec = record
- display: displayRec;
- keyBuf, userKeyBuf: string;
- curTextHand: Handle;
- nodeAction: nodeActionType;
- yesDefault, critical, nodeClosing, abortListing, pauseEnabled, resolveTextPercents: boolean;
- noReturn, useUserkeyBuf, transInProgress: boolean;
- typeConn: portType;
- lenPrompt, numPrompt, curEditor, curExtern, curNum, lenChat, portNum, connRefnum: integer;
- timesCritical, transRefnum, editRefnum, externRefnum: integer;
- curTextPos, curTextSize, loginTime, lastKeypress, lastBlink, textStart: longint;
- cps, maxPrompt: longint;
- promptProc, quitHandlerProc: ProcPtr;
- thisUser: userRec;
- curPath, curPrompt, curAnswer, curCommand, curParams, shellPrompt, pauseAccepted, interNode: string;
- numParams, curMenu, shellMenu: integer;
- savedNodeAction: array[1..4] of nodeActionType;
- whichShell: ShellType;
- specialPrompt: (Normal, Command, Password, WordWrap);
- shellSection: (InitShell, BeforePrompt, MainPrompt, BeforeGo, GoSection);
- sysopPos, userPos: point;
- savedUseUserKeyBuf, inSlash: boolean;
- joinData: joinHand;
- mailIndex: mailIndexHand;
- curChat, curSysChat: string[80];
- savedVarient: ptr;
- subject: string[80];
- case nodeSection : NodeSectionType of
- Logon: (
- logonSection: (Welcome, NamePrompt, PassPrompt, CheckInfo, LogonFile, CheckBulletins, CheckMail, ToShell);
- lvRefnum, logonIndex: integer;
- lDirID: longint;
- );
- NewUser: (
- newUserSection: (NUPText, NUPPrompt, CheckNup, AccessCode, CheckCode, NewUserText, NewUserName, NewName, NewPhone, NewBirth, NewSex, NewPassword, VerifyPassword, SaveUserInfo);
- question: boolean;
- );
- ListingUsers: (
- curUser: integer;
- loadedUser: userRec;
- );
- Feedback: (
- feedbackSection: (FeedbackText, FeedbackPrompt, SendFeedback);
- );
- Mailing: (
- mailingSection: (ReplyMail, WhoTo, MailSubject, MailEdit, SaveMail);
- curMailing: str16;
- curDomainAddr: string[80];
- );
- ReadingMail: (
- rmSection: (InitRm, RmPrompt, RmProcess, ListRm, CloseRm);
- rmRefnum, numMail, curMail, rmTi: integer;
- );
- Chat: (
- chatSection: (ChatText, ChatYesNo, ReasonPrompt, Beep);
- );
- Select: (
- selectSection: (AskGroup, SelectAction);
- );
- Rn, Post: (
- rnSection: (InitRn, CheckGroup, AskRead, ProcessAnswer, ReadMessage, RnPrompt, RnAction, RnSecond, ListingTitles, InitSearch, Searching, Posting, CatchUp, RnWriting, RnBatchWrite, CloseRn);
- curGroup: integer;
- search: string[40];
- references: string;
- curMess, curPost, rnTli: longint;
- read, searchForward: boolean;
- case integer of
- 1: (
- batchWriteSection: (BWCheck, BWFilenameP, BWInit, PerformBW);
- bwFrom, bwTo: longint;
- );
- 2: (
- postingSection: (PostReply, PostSubject, PostEdit, SavePost);
- postSection: (PostCommandline, GroupAction, InitPost, DoingPost, ClosePost);
- );
- );
- Join: (
- joinSection: (JoinCommandline, InitJoin, ListGroups, ListingGroups, JoinReturn, JoinPrompt, JoinAction, CloseJoin);
- joinGroup, joinNum: integer;
- joining: boolean; {Joining or unjoining?}
- );
- Finger: (
- FingerSection: (InitFinger, ConnFinger, ConnectingFinger, DoingFinger, CloseFinger);
- fingerConn: integer;
- fingerBuf: handle;
- );
- Telnet: (
- TelnetSection: (InitTelnet, ConnTelnet, ConnectingTelnet, DoingTelnet, CloseTelnet);
- teln: record
- conn: integer;
- buf, expectBuf: handle;
- inOption: boolean;
- port, curParam: integer;
- status: longint;
- option: string[2];
- end;
- );
- Page: (
- pageSection: (PageText, PagePrompt, SendPage);
- );
- AreYouSure: (
- sureSection: (AskSure, CheckAndExec);
- sureType: (OffAYS, LoginAYS);
- );
- ChangeShell: (
- changeShellSection: (CSText, ChangeShellPrompt, SetShell);
- );
- ChangeEdit: (
- changeEditSection: (CEText, ChangeEditPrompt, SetEdit);
- );
- Edit: (
- editSection: (InitEdit, CreateFile, OpenFileEdit, EditFile);
- editFileRefnum: integer;
- );
- Help: (
- helpSection: (DispMenu, HelpPrompt, PromptAction);
- helpPath: string[80];
- helpLevel: integer;
- );
- Redirect: (
- redirectSection: (InitRedirect, DoingRedirect, CleanUpRedirect);
- redirectPort: integer;
- lastCntrlX: longint;
- );
- OneLiner: (
- oneLinerSection: (AskNode, CheckNode, AskOneLiner, SendOneLiner);
- oneLinerNode: integer;
- );
- MultiChat: (
- multiChatSection: (InitMulti, ListMultiUsers, MultiPrompt, DoMulti);
- );
- Download: (
- dlSection: (FilePrompt, DoFind, ProtoPrompt, DoDown);
- );
- end;
- userIndexRec = record
- name: str16;
- num: longint;
- end;
- userIndexHand = ^userIndexPtr;
- userIndexPtr = ^userIndexArr;
- userIndexArr = array[1..32768] of userIndexRec;
-
- typeGroupType = (Local, Usenet, Fidonet);
- groupRec = record
- groupName: string[58];
- min, max, lastScan, dirID: longint;
- validBits, vRefnum, hash, keep: integer;
- readAcs, postAcs: string[25];
- typeGroup: typeGroupType;
- anon, new: boolean;
- end;
- groupHand = ^groupPtr;
- groupPtr = ^groupArr;
- groupArr = array[1..32768] of groupRec;
-
- sectionRec = record
- sectionName: string[58];
- lookAcs, dlAcs, ulAcs: string[25];
- free: boolean;
- dirID: longint;
- vRefnum, validityBits: integer;
- res: packed array[1..42] of byte;
- end;
- sectionHand = ^sectionPtr;
- sectionPtr = ^sectionArr;
- sectionArr = array[1..32768] of sectionRec;
-
- commandsRec = record
- hotkey: char;
- slash, enabled: boolean;
- mainMenu: str32;
- acs, description: string[25];
- end;
- commandsArr = array[1..32768] of commandsRec;
- commandsHand = ^commandsPtr;
- commandsPtr = ^commandsArr;
-
- menuRec = record
- menuName: str32;
- menuPrompt: string;
- numCommands: integer;
- commands: commandsHand;
- end;
-
- cookieIndexHand = ^cookieIndexPtr;
- cookieIndexPtr = ^cookieIndexArr;
- cookieIndexArr = array[1..32768] of longint;
-
- modemStrType = (InitStr, ChangeSpeed, HWOn, HWOff, DtrOn, DtrOff, Answer, HangupStr, Quit);
-
- MailQueueHand = ^MailQueuePtr;
- MailQueuePtr = ^MailQueueArr;
- MailTypeType = (STMPClient, STMPServer, POP2);
- MailQueueRec = record
- connRefnum: integer;
- stage: (Opening, Commanding, Reading, Done);
- received: string;
- case mailType : MailTypeType of
- STMPClient: (
- stmpCommand: (Helo, MailCmd, Rcpt, Data, Close);
- mailHand: handle;
- );
- STMPServer: (
- );
- POP2: (
- popCommand: (HeloCmd, ReadCmd, Retr, CloseCmd);
- userName, password: str16;
- count, bytesReceived: longint;
- receiveHand: handle;
- );
- end;
- MailQueueArr = array[1..100] of MailQueueRec;
-
- {Insert All Declerations Here:}
- privatesHand = Handle;
- {End of User Declerations}
-
- editParamsPtr = ^editParamsRec;
- editParamsRec = record
- message: byte;
- nodeGlobs: nodeGlobPtr;
- privates, globals: privatesHand;
- externRefnum, appRefnum: integer;
- reserved: packed array[1..96] of char;
- procs: array[1..25] of ProcPtr;
- end;
-
- {End of extern common}
-
- var
- mailQueue: MailQueueHand;
- rootPath: string;
- usersRef, cookiesRef, appRefnum, numNodes, curNode, pppOpened: integer;
- userIndex: userIndexHand;
- cookieIndex: cookieIndexHand;
- groups: groupHand;
- system: systemRec;
- portSav: array[1..MaxPorts] of portSavRec;
- portGlobs: array[1..MaxPorts] of portGlobRec;
- nodeGlobPtrs: array[1..MaxNodes] of nodeGlobPtr;
- menus: array[1..MaxMenus] of menuRec;
- nodeGlobs: nodeGlobPtr;
- boardGlobs: boardGlobRec;
- mouseRgn: RgnHandle;
- AppleMenu, FileMenu, FileSubMenu, EditMenu, SysopMenu, SpecialMenu, WindowsMenu: MenuHandle;
- startupTime, startupTicks, lastMoved, lastIdle: longint;
- resolvePercents, noPorts, inThink: boolean;
-
- function s2i (t1: str255): longint;
- function i2s (t1: longint): string;
- function EnoughMemory (size: longint): boolean;
- procedure SetNodeAction (action: NodeActionType);
- procedure RestoreNodeAction;
- procedure Error (fatal: boolean; str: string);
- function Sure (str: string): boolean;
- procedure DumpHand (hand: handle);
-
- function PppUp: OSErr;
- function PppOpen: OSErr;
- function PppClose (hard: boolean): OSErr;
-
- implementation
-
- {$IFC MWerks}
- function PppUp: OSErr;
- begin
- PPPUp := -1;
- end;
-
- function PppOpen: OSErr;
- begin
- PppOpen := -1;
- end;
-
- function PppClose (hard: boolean): OSErr;
- begin
- PppClose := -1;
- end;
- {$ENDC}
-
- function s2i (t1: str255): longint;
- var
- t2: longint;
- begin
- StringToNum(t1, t2);
- s2i := t2
- end;
- function i2s (t1: longint): string;
- var
- t2: str255;
- begin
- NumToString(t1, t2);
- i2s := t2
- end;
-
- function EnoughMemory (size: longint): boolean;
- begin
- if (FreeMem - size > longint(MemBuffer)) then
- EnoughMemory := true
- else if (CompactMem(size + longint(MemBuffer)) - size >= longint(MemBuffer)) then
- EnoughMemory := true
- else
- begin
- PurgeMem(size);
- EnoughMemory := (CompactMem(size + longint(MemBuffer)) - size >= longint(MemBuffer));
- end;
- end;
-
- procedure SetNodeAction (action: NodeActionType);
- begin
- with nodeGlobs^ do
- begin
- savedNodeAction[4] := savedNodeAction[3];
- savedNodeAction[3] := savedNodeAction[2];
- savedNodeAction[2] := savedNodeAction[1];
- savedNodeAction[1] := NodeAction;
- NodeAction := action;
- end;
- end;
-
- procedure RestoreNodeAction;
- begin
- with nodeGlobs^ do
- begin
- NodeAction := savedNodeAction[1];
- savedNodeAction[1] := savedNodeAction[2];
- savedNodeAction[2] := savedNodeAction[3];
- savedNodeAction[3] := savedNodeAction[4];
- savedNodeAction[4] := None;
- end;
- end;
-
- procedure Error (fatal: boolean; str: string);
- var
- dItem: integer;
- begin
- ParamText(str, '', '', '');
- if fatal then
- dItem := StopAlert(141, nil)
- else
- dItem := CautionAlert(141, nil);
- end;
-
- function Sure (str: string): boolean;
- begin
- ParamText(str, '', '', '');
- Sure := StopAlert(142, nil) = 2;
- end;
-
- procedure DumpHand (hand: handle);
- var
- wind: windowPtr;
- r: rect;
- event: EventRecord;
- begin
- {$IFC MWerks}
- r := qd.screenBits.bounds;
- {$ELSEC}
- r := screenBits.bounds;
- {$ENDC}
- InsetRect(r, 50, 50);
- wind := NewWindow(nil, r, 'Dump', true, 4, windowPtr(-1), true, 0);
- SetPort(wind);
- TextFont(Geneva);
- TextSize(9);
- {$IFC MWERKS}
- TETextBox(hand^, GetHandleSize(hand), wind^.portRect, teJustLeft);
- {$ELSEC}
- TextBox(hand^, GetHandleSize(hand), wind^.portRect, teJustLeft);
- {$ENDC}
- repeat
- until GetOSEvent(everyEvent, event);
- DisposeWindow(wind);
- end;
- end.